﻿<views:WindowBase
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Converters="clr-namespace:PortUtil.Converters"
    xmlns:views="clr-namespace:PortUtil.Views"
    x:Class="PortUtil.Views.MainWindow" WindowStartupLocation="CenterScreen"
    Title="COM Port Utility" Height="382.5" Width="603.5" Closing="WindowBase_Closing" Icon="/PortUtil;component/Assets/cmd.ico">


    <Window.Resources>
        <Converters:BoolToConnectionIndicatorConverter x:Key="BoolToConnectionIndicatorConverter" />
    </Window.Resources>
    <Window.DataContext>
        <Binding Mode="OneWay" Path="ConsoleViewModel" Source="{StaticResource Locator}" />
    </Window.DataContext>

    <DockPanel>
        <Menu x:Name="Menu" DockPanel.Dock="Top">
            <MenuItem Header="File">
                <MenuItem Header="New session..." Command="{Binding NewSessionCommand}" InputGestureText="Ctrl+N">
                    <MenuItem.Icon>
                        <Image Source="../Assets/NewRequest_8796.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Terminate session" IsEnabled="{Binding IsSessionOpen}"
                          Command="{Binding Path=EndSessionCommand}">
                </MenuItem>
                <Separator />
                <MenuItem Header="Save As..." Command="{Binding SaveCommand}" InputGestureText="Ctrl+S">
                    <MenuItem.Icon>
                        <Image Source="../Assets/Save_6530.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Print..." Command="{Binding PrintCommand}" InputGestureText="Ctrl+P">
                    <MenuItem.Icon>
                        <Image Source="../Assets/Print_11009.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Exit" Command="{Binding QuitCommand}" InputGestureText="Alt+F4" />
            </MenuItem>
            <MenuItem Header="Edit">
                <MenuItem Header="Cut" Command="{Binding CutCommand}" InputGestureText="Ctrl+X" >
                    <MenuItem.Icon>
                        <Image Source="../Assets/Cut_6523.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Copy" Command="{Binding CopyCommand}" InputGestureText="Ctrl+C">
                    <MenuItem.Icon>
                        <Image Source="../Assets/Copy_6524.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Paste" Command="{Binding PasteCommand}" InputGestureText="Ctrl+V" >
                    <MenuItem.Icon>
                        <Image Source="../Assets/Paste_6520.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Paste and Send" Command="{Binding PasteAndSendCommand}" InputGestureText="Ctrl+Shift+V" />
                <Separator />
                <MenuItem Header="Select All" Command="{Binding SelectAllCommand}" InputGestureText="Ctrl+A" >
                    <MenuItem.Icon>
                        <Image Source="../Assets/Select.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Clear Screen" Command="{Binding ClearCommand}" InputGestureText="Ctrl+I">
                    <MenuItem.Icon>
                        <Image Source="../Assets/Clearwindowcontent_6304.png"></Image>
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="View">
                <MenuItem x:Name="menuItem" Header="Maximized Screen"
                          IsChecked="{Binding IsMaximized, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type views:MainWindow}}}"
                          IsCheckable="True" Command="{Binding MaximizeScreenCommand}"
                          InputGestureText="Shift+Alt+Enter" />
            </MenuItem>
            <MenuItem Header="Tools">
                <!--<MenuItem Header="Key Mapping" />
                <Separator />-->
                <MenuItem Header="Options..." Command="{Binding SettingsCommand}" />
            </MenuItem>
            <MenuItem Header="Help">
                <MenuItem x:Name="AboutMenuItem" Header="About COM Port Utility" Click="AboutMenuItem_Click" />
            </MenuItem>
        </Menu>
        <StatusBar x:Name="StatusBar" DockPanel.Dock="Bottom">
            <StatusBarItem
                Content="{Binding IsSessionOpen, Converter={StaticResource BoolToConnectionIndicatorConverter}, Mode=OneWay}" />
        </StatusBar>
        <TextBox x:Name="ConsoleBox" Background="Black" VerticalScrollBarVisibility="Visible"
                 HorizontalScrollBarVisibility="Auto" TextWrapping="Wrap" AcceptsReturn="True" FontFamily="Consolas"
                 FontSize="13" Foreground="White" Padding="0" IsReadOnly="True" IsReadOnlyCaretVisible="True">

            <TextBox.InputBindings>
                <KeyBinding Key="N" Modifiers="Control" Command="{Binding NewSessionCommand}" />
                <KeyBinding Key="S" Modifiers="Control" Command="{Binding SaveCommand}" />
                <KeyBinding Key="F4" Modifiers="Control+Alt" Command="{Binding QuitCommand}" />
                <KeyBinding Key="X" Modifiers="Control" Command="{Binding CutCommand}" />
                <KeyBinding Key="C" Modifiers="Control" Command="{Binding CopyCommand}" />
                <KeyBinding Key="V" Modifiers="Control" Command="{Binding PasteCommand}" />
                <KeyBinding Key="V" Modifiers="Control+Shift" Command="{Binding PasteAndSendCommand}" />
                <KeyBinding Key="I" Modifiers="Control" Command="{Binding ClearCommand}" />
                <KeyBinding Key="P" Modifiers="Control" Command="{Binding PrintCommand}" />
                <KeyBinding Key="A" Modifiers="Control" Command="{Binding SelectAllCommand}" />
                <KeyBinding Key="Enter" Modifiers="Shift+Alt"
                            Command="{Binding MaximizeScreenCommand, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type views:MainWindow}}}" />
            </TextBox.InputBindings>

            <TextBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Cut" Command="{Binding CutCommand}" InputGestureText="Ctrl+X" >
                        <MenuItem.Icon>
                            <Image Source="../Assets/Cut_6523.png"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Copy" Command="{Binding CopyCommand}" InputGestureText="Ctrl+C">
                        <MenuItem.Icon>
                            <Image Source="../Assets/Copy_6524.png"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Paste" Command="{Binding PasteCommand}" InputGestureText="Ctrl+V" >
                        <MenuItem.Icon>
                            <Image Source="../Assets/Paste_6520.png"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Paste and Send" Command="{Binding PasteAndSendCommand}" InputGestureText="Ctrl+Shift+V" />
                    <Separator />
                    <MenuItem Header="Select All" Command="{Binding SelectAllCommand}" InputGestureText="Ctrl+A" >
                        <MenuItem.Icon>
                            <Image Source="../Assets/Select.png"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator />
                    <MenuItem Header="Clear Screen" Command="{Binding ClearCommand}" InputGestureText="Ctrl+I">
                        <MenuItem.Icon>
                            <Image Source="../Assets/Clearwindowcontent_6304.png"></Image>
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </TextBox.ContextMenu>

        </TextBox>
    </DockPanel>
</views:WindowBase>